package com.ruoyi.web.controller.zhishiku;

import com.ruoyi.common.core.domain.vo.UpdateAuthGrantVO;
import com.ruoyi.common.core.query.AuthListQuery;
import com.ruoyi.system.service.FileAuthRefService;
import com.ruoyi.system.service.FileAuthService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@AllArgsConstructor
@RequestMapping("/zhishiku/permission")
//@ApiOperation("")
public class FilePremissionController {


    private final FileAuthService fileAuthService;

    private final FileAuthRefService fileAuthRefService;

    @ApiOperation("获取所有的角色和用户")
    @GetMapping("/getUserAndRole")
    public List<Map<String, Object>> selectUserAndRoleList() {
        return fileAuthRefService.selectUserAndRoleList();
    }

    @ApiOperation("获取所有的权限")
    @GetMapping("/getAuthList")
    public List<Map<String, Object>> selectAuthList() {
        return fileAuthService.selectAuthList();
    }

    @ApiOperation("根据对象和文件获取所有的权限")
    @PostMapping("/getAuthListByFileId")
    public List<Map<String, Object>> selectAuthListByFileId(@RequestBody AuthListQuery authListQO) {
        return fileAuthService.selectFileAuthRefByRefIdAndFileId(authListQO);
    }

    @ApiOperation("插入权限")
    @PostMapping("/insertAuth")
    public boolean insertAuth(@RequestBody UpdateAuthGrantVO authListQO) {
        return fileAuthRefService.insertFileAuthRef(authListQO);
    }




}
